package com.qindian;

import android.graphics.Paint;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.qindian.coupontest.R;
import com.qindian.coupontest.TimeFormatUtil;
import com.qindian.model.ExchangedCouponModel;

/**
 * Author: Li
 * Date: 2018/5/3 0003
 * Description:
 */

public class ExchangedCouponsAdapter extends BaseQuickAdapter<ExchangedCouponModel.DataBean.ListBean,BaseViewHolder> {
    public ExchangedCouponsAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, ExchangedCouponModel.DataBean.ListBean item) {

        Glide.with(mContext).load(item.getItempic()).into((ImageView) helper.getView(R.id.img_exchanged_coupon));
        helper.setText(R.id.txt_exchanged_order,"订单号："+item.getOrder_sn());
        helper.setText(R.id.txt_exchanged_title,item.getTitle());
        helper.setText(R.id.txt_exchanged_coupon_time, "领券时间："+TimeFormatUtil.format(item.getAdd_time()*1000,"yyyy-MM-dd HH:mm"));
        helper.setText(R.id.txt_exchanged_coupon_price,"已优惠："+item.getShop_price());

        String originPrice="";
        switch (item.getIsjd()) {
            case 1:
                originPrice="京东价："+item.getOrigin_price();
                break;
            case 0:
                originPrice="淘宝价："+item.getOrigin_price();
                break;
        }
        helper.setText(R.id.txt_exchanged_price,originPrice);
        ((TextView) helper.getView(R.id.txt_exchanged_price)).getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG|Paint.DITHER_FLAG);


    }
}
